//
//  RCUserVCOrderListCell.m
//  RocketProject
//
//  Created by chen jiedan on 13-8-25.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "RCUserVCOrderListCell.h"
#import "UIColor-Expanded.h"
#import "UIImageView+WebCache.h"
#import "CommonDefines.h"
#import "GloableEngineService.h"


@implementation RCUserVCOrderListCell{
    UIImageView *_leftImageView;
    UILabel     *_headLabel;
    UILabel     *_priceLabel;
    UILabel     *_stateLabel;
    
    UIButton    *_orderDetailBtn;

}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self createPlaceHolder];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void) createPlaceHolder
{
    _leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 20, 80, 60)];
    [self.contentView addSubview:_leftImageView];
    [_leftImageView release];
    
    _headLabel = [[UILabel alloc] initWithFrame:CGRectMake(110, 20, 120, 20)];
    [self.contentView addSubview:_headLabel];
    [_headLabel setBackgroundColor:[UIColor clearColor]];
    _headLabel.textColor = [UIColor colorWithRed:80.0/255 green:80.0/255 blue:80.0/255 alpha:1];
    _headLabel.font = [UIFont fontWithName:kFontNameHelvetica size:15];
    [_headLabel release];
    
    
    _priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(110, 50, 120, 15)];
    [self.contentView addSubview:_priceLabel];
    [_priceLabel setBackgroundColor:[UIColor clearColor]];
    _priceLabel.font =[UIFont fontWithName:kFontNameHelvetica size:12];
    _priceLabel.textColor = kNormalTextColor;
    [_priceLabel release];
    
    _stateLabel = [[UILabel alloc] initWithFrame:CGRectMake(110, 65, 120, 15)];
    [self.contentView addSubview:_stateLabel];
    [_stateLabel setBackgroundColor:[UIColor clearColor]];
    _stateLabel.font =[UIFont fontWithName:kFontNameHelvetica size:12];
    _stateLabel.textColor = kNormalTextColor;
    [_stateLabel release];
    
    _orderDetailBtn = [[UIButton alloc] initWithFrame:CGRectMake(245, 40, 62, 22)];
    [_orderDetailBtn setBackgroundImage:[UIImage imageNamed:@"RCUserVC_Order_Detail"] forState:UIControlStateNormal];
    [self.contentView addSubview:_orderDetailBtn];
    [_orderDetailBtn release];
    
    UIView *horizonLine = [[UIView alloc]initWithFrame:CGRectMake(15, 94, 320-30, 1)];
    horizonLine.backgroundColor = [UIColor colorWithHex:0xffe6e6e6];
    [self.contentView addSubview:horizonLine];
    [horizonLine release];
    
}

- (void) bindData:(RCMyOrderItemDataModel *)item
{
    [_leftImageView setImageWithURL:nil placeholderImage:[UIImage imageNamed:@"icon_RCUserVCOrderListIMG"]];
    _headLabel.text = item.shopName;
    _priceLabel.text = @"￥82";
    _stateLabel.text = item.status;
    
}
@end


@implementation RCUserOrderListHeaderCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        UILabel *shopLabel = [[UILabel alloc] initWithFrame:CGRectMake(160-90, 10, 180, 20)];
        [self.contentView addSubview:shopLabel];
        [shopLabel setBackgroundColor:[UIColor clearColor]];
        shopLabel.textColor = kNormalHeadTextColor;
        shopLabel.font = [UIFont fontWithName:kFontNameHelvetica size:14];
        shopLabel.text = [[GloableEngineService sharedInstance] nickName];
        shopLabel.textAlignment = NSTextAlignmentCenter;
        [shopLabel release];
        [self.contentView setBackgroundColor:[UIColor colorWithRed:230.0/255 green:230.0/255 blue:230.0/255 alpha:1]];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}


@end

@implementation RCUserOrderListCell{

    UILabel     *_shopName;
    UILabel     *_staus;
    UILabel     *_userName;
    UILabel     *_phoneLabel;
    UILabel     *_orderTime;
    UILabel     *_comment;
    
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self createPlaceHolder];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (void) createPlaceHolder
{
  
    UILabel *shopLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 70, 20)];
    [self.contentView addSubview:shopLabel];
    [shopLabel setBackgroundColor:[UIColor clearColor]];
    shopLabel.textColor = kNormalTextColor;
    shopLabel.font = [UIFont fontWithName:kFontNameHelvetica size:14];
    shopLabel.text = @"名称";
    [shopLabel release];
    
    
    _shopName = [[UILabel alloc] initWithFrame:CGRectMake(85, 10, 170, 15)];
    [self.contentView addSubview:_shopName];
    [_shopName setBackgroundColor:[UIColor clearColor]];
    _shopName.textColor = kNormalHeadTextColor;
    _shopName.font = [UIFont fontWithName:kFontNameHelvetica size:14];
    [_shopName release];
    
   
    
    _staus = [[UILabel alloc] initWithFrame:CGRectMake(255, 10, 120, 15)];
    [self.contentView addSubview:_staus];
    [_staus setBackgroundColor:[UIColor clearColor]];
    _staus.font =[UIFont fontWithName:kFontNameHelveticaBold size:12];
    _staus.textColor = kNormalOrangeTextColor;
    [_staus release];
    
    
    UILabel *userLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, 60, 15)];
    [self.contentView addSubview:userLabel];
    [userLabel setBackgroundColor:[UIColor clearColor]];
    userLabel.textColor = kNormalTextColor;
    userLabel.font = [UIFont fontWithName:kFontNameHelvetica size:14];
    userLabel.text = @"预订人";
    [userLabel release];
    
    _userName = [[UILabel alloc] initWithFrame:CGRectMake(85, 30, 120, 15)];
    [self.contentView addSubview:_userName];
    [_userName setBackgroundColor:[UIColor clearColor]];
    _userName.font =[UIFont fontWithName:kFontNameHelvetica size:14];
    _userName.textColor = kNormalHeadTextColor;
    [_userName release];
    

    _phoneLabel = [[UILabel alloc] initWithFrame:CGRectMake(225, 30, 120, 15)];
    [self.contentView addSubview:_phoneLabel];
    [_phoneLabel setBackgroundColor:[UIColor clearColor]];
    _phoneLabel.font =[UIFont fontWithName:kFontNameHelvetica size:14];
    _phoneLabel.textColor = kNormalTextColor;
    [_phoneLabel release];
    
    UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 50, 60, 15)];
    [self.contentView addSubview:timeLabel];
    [timeLabel setBackgroundColor:[UIColor clearColor]];
    timeLabel.textColor = kNormalTextColor;
    timeLabel.font = [UIFont fontWithName:kFontNameHelvetica size:14];
    timeLabel.text = @"预订时间";
    [timeLabel release];
    
    _orderTime = [[UILabel alloc] initWithFrame:CGRectMake(85, 50, 200, 15)];
    [self.contentView addSubview:_orderTime];
    [_orderTime setBackgroundColor:[UIColor clearColor]];
    _orderTime.font =[UIFont fontWithName:kFontNameHelvetica size:14];
    _orderTime.textColor = kNormalHeadTextColor;
    [_orderTime release];
    
    UILabel *commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 70, 60, 15)];
    [self.contentView addSubview:commentLabel];
    [commentLabel setBackgroundColor:[UIColor clearColor]];
    commentLabel.textColor = kNormalTextColor;
    commentLabel.font = [UIFont fontWithName:kFontNameHelvetica size:14];
    commentLabel.text = @"备注";
    [commentLabel release];
    
    _comment = [[UILabel alloc] initWithFrame:CGRectMake(85, 70, 120, 15)];
    [self.contentView addSubview:_comment];
    [_comment setBackgroundColor:[UIColor clearColor]];
    _comment.font =[UIFont fontWithName:kFontNameHelvetica size:14];
    _comment.textColor = kNormalHeadTextColor;
    [_comment release];
    
    UIView *horizonLine = [[UIView alloc]initWithFrame:CGRectMake(15, 94, 320-30, 1)];
    horizonLine.backgroundColor = [UIColor colorWithHex:0xffe6e6e6];
    [self.contentView addSubview:horizonLine];
    [horizonLine release];
    
}

- (void) bindData:(RCMyOrderItemDataModel *)item
{
  
    _shopName.text = item.shopName;
    _staus.text = item.status;
    _userName.text = item.userName;
    NSTimeInterval timeInMiliseconds = [item.dateTime longLongValue];
    NSDate* date = [NSDate dateWithTimeIntervalSince1970:timeInMiliseconds];

    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *stringFromDate = [formatter stringFromDate:date];
    [formatter release];
    
    _orderTime.text = stringFromDate;
    _phoneLabel.text = item.mobile;
    _comment.text = item.content;
    
    
}
@end
